package com.blacktech.dbu.core.config;

import com.blacktech.dbu.meta.entity.*;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer;
import org.springframework.web.servlet.config.annotation.CorsRegistry;

/**
 * Web配置
 *
 * @author yanyunsong
 */
@Configuration
public class WebConfig implements RepositoryRestConfigurer {

    @Override
    public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config, CorsRegistry cors) {
        // 暴露实体的ID字段
        config.exposeIdsFor(DbuProduct.class);
        config.exposeIdsFor(DbuSchema.class);
        config.exposeIdsFor(DbuTable.class);
        config.exposeIdsFor(DbuColumn.class);
        config.exposeIdsFor(DbuConstraint.class);
        config.exposeIdsFor(DbuDictionary.class);

        // 设置基础路径
        config.setBasePath("/api");
    }
}